package com.ss.ttvideoengine.a;

import com.ss.ttvideoengine.b.VideoDataContainer;
import com.ss.ttvideoengine.c.HttpRequest.Callback;
import com.ss.ttvideoengine.d.TTVideoError;

import org.json.JSONObject;

final class b implements Callback {
    private com.ss.ttvideoengine.a.a a;

    b(com.ss.ttvideoengine.a.a arg1) {
        this.a = arg1;

    }

    public final void callback(JSONObject respJo, TTVideoError error) {
        com.ss.ttvideoengine.a.a v1;
        if (respJo == null || error != null) {
            v1 = this.a;
            synchronized (v1) {
                if (!v1.b) {
                    TTVideoError videoError;
                    if (error != null) {
                        videoError = new TTVideoError("kTTVideoErrorDomainFetchingInfo", -9994, error.description);
                    } else {
                        videoError = new TTVideoError("kTTVideoErrorDomainFetchingInfo", -9994);
                    }
                    if (v1.c <= 0) {
                        v1.a.sendMessage(v1.a.obtainMessage(0, videoError));
                        ++v1.c;
                        v1.a();
                    } else {
                        v1.a(videoError);
                    }
                    return;
                }
                return;
            }
        } else {
            v1 = this.a;
            synchronized (v1) {
                if (v1.b) {

                } else {
                    VideoDataContainer videoDataContainer = new VideoDataContainer();
                    videoDataContainer.initWithJO(respJo);
                    if (respJo.optInt("code") != 0) {
                        if (videoDataContainer.mVideoInfo != null && videoDataContainer.mVideoInfo.status != 10) {
                            v1.a.sendMessage(v1.a.obtainMessage(3, videoDataContainer.mVideoInfo.status, 0));
                        } else {
                            v1.a(new TTVideoError("kTTVideoErrorDomainFetchingInfo", -9998, respJo.toString()));
                        }
                    } else {
                        v1.a.sendMessage(v1.a.obtainMessage(2, videoDataContainer));
                    }
                }
            }
        }
    }
}

